package com.guohengspace.mq.utils;

import org.slf4j.MDC;

import java.util.UUID;

/**
 * @author zhangfei
 * @date 2023/3/30 20:49
 */
public class TraceUtil {
    private static final String TRACEID = "traceId";
    public  static void traceId(){
        MDC.put(TRACEID, UUID.randomUUID().toString().replace("-",""));
    }

    public  static void traceId(String  traceId ){
        MDC.put(TRACEID, traceId);
    }

    public static void clear(){
        MDC.clear();
    }

    public static String getTraceid(){
        return MDC.get(TRACEID);
    }
}
